March 96 - Macintosh Q & A
Macintosh Q & A
Q I'm having problems with our caching drivers on the Power Macintosh 9500. Our
drivers allocate a large amount of RAM (up to 4 MB) early in the boot process. If I set
the driver's cache size to 4 MB, the computer locks up as soon as the driver is
executed. If I set the cache size to 2 MB, the driver loads and executes properly, but
the computer gets a bus error much later in the boot process (after MacsBug loads and
after the Mac OS screen is displayed, but before the Finder executes). If I set the cache
size to 1 MB, everything runs properly. What's going on here?
A Because of Open Firmware requirements, the boot stack on the new Power
Macintosh 9500 CPUs was changed to 4 MB. As a result, you can't grow the system
heap past 4 MB or a system crash will occur. If possible, try to defer allocating
memory until INIT time. The 'sysz' mechanism is supported by the enabler ('boot' 3)
when INITs are being loaded.
QWe want to maximize our throughput across the PCI bus between Macintosh memory
and a block of static RAM on our card. This static RAM is also accessible from an
on-card DSP, which constantly reads/modifies RAM. The DSP isn't directly on the PCI
bus, so it can't easily participate in cache coherency schemes. What's the best way to
get data across the PCI bus to and from this memory?
A The PowerPC processor can only burst to and from a cacheable memory space.
Your best option is to use BlockMoveDataUncached. This doesn't use burst transfers,
but rather uses floating-point loads and stores. You may want to design your own
algorithms, using the double declaration in C to get compilers to translate
BlockMoveDataUncached into floating-point loads and stores. For more information,
see Chapter 9 of Designing PCI Cards and Drivers for Power Macintosh Computers, and
Technote 1008, "Understanding PCI Bus Performance.
QThe Power Macintosh 9500 Developer Note says that the sound-in port for the 9500
has 4-conductor requirements. What is the 4-conductor pinout? Does the PlainTalk
microphone work on the 9500?
A The 9500 has stereo in (supporting left, right, power, and ground) and requires a
mini stereo plug that you can buy today -- no wacky new pinouts. The PlainTalk
microphone works fine on the 9500.
QIs there any information on writing native SCSI disk drivers for the PCI-based
Power Macintosh computers? In particular, what's the proper way to install a native
driver on a SCSI disk: is there a special partition type for a native driver, or should
there be a standard SCSI disk driver that loads a PowerPC code fragment?
A Apple doesn't support native SCSI drivers yet (this will be a feature of Copland,
the next generation of the Mac OS). You can write a native SCSI Interface Module
(SIM). Remember that a driver is the software that handles a particular SCSI device,
while a SIM is responsible for SCSI controllers (for example, PCI or NuBus(TM)
cards).
Normally, SCSI 4.3 drivers are loaded off the Apple_Driver43 partition, and SIMs are
typically loaded from the disk controller firmware (PCI card). If you want to load a
native SIM off of the disk, you'll have to encapsulate the code fragments and read and
link them in from your standard 680x0 driver.
QWe have SCSI routines that transfer 64K data blocks (to get the highest transfer
rates possible with the tape drive we're using). On the Power Macintosh (8100/80 or
8100/100), if the mouse is moved during a 64K transfer, the cursor is jumpy.
Lowering the cache size to 16K reduces the problem to an acceptable level but kills the
transfer rates. We're using SCSI Manager 4.3. How do we avoid the jumpy cursor
while maintaining maximum throughput?
A Your jumpy cursor is an indication that you aren't properly implementing SCSI
direct memory access (DMA). When using the 8100 (and PCI-based machines) for
DMA transfer efficiency, you should ensure the following:
• Your data is aligned on 8-byte block boundaries. Since the DMA hardware
can't do odd transfers, it must perform programmed I/O to handle at least part
of the transfer if the data isn't aligned.
• Your physical memory buffer is contiguous (which you ensure by calling
LockMemoryContiguous). Otherwise, the DMA transfer will have to be broken
up; this will especially be a problem if virtual memory is turned on.
Also, if you have disconnects enabled in your device or driver, it's possible that the
transfer is getting broken up and some VBL activity is occurring. The bottom line is
that you don't want a SCSI disconnect to occur during your transfer.
QIs it possible to create and resolve aliases asynchronously?
A No, you can't resolve aliases asynchronously because the Alias Manager uses all
synchronous File Manager and Device Manager requests.
QIs there a QuickTime codec for converting QuickDraw GX pictures to QuickDraw PICT
format? If so, can you provide this?
A At a session during Apple's 1995 Worldwide Developers Conference, a new
technique for exporting QuickDraw GX pictures as QuickDraw PICT files was
demonstrated. The method makes use of QuickTime and a new codec that's included in
the QuickDraw GX extension version 1.1 and later. With this codec, you can embed a
flattened QuickDraw GX picture into a PICT file (or a QuickTime movie). We
recommend that you use this method if you want to allow your QuickDraw GX
application to exchange pictures with existing QuickDraw applications. You can find
sample code demonstrating the use of this codec in the Macintosh Technical Q&A
"Embedding a GX Picture into a PICT" (GX 07).
One important feature of this codec is that it does not convert QuickDraw GX pictures to
QuickDraw PICTs in the traditional sense of the word "convert." What it allows is the
embedding of QuickDraw GX objects inside a PICT file. The advantage of this is that it
allows QuickDraw GX pictures to be viewed (but not edited) in any application that can
open a PICT file. Although "embedding" is very useful, it's quite different from
"conversion.
Strictly speaking, it's not possible to convert QuickDraw GX pictures to QuickDraw
PICTs without loss of information, because QuickDraw GX has much greater
functionality than traditional QuickDraw. You can, of course, draw the QuickDraw GX
picture offscreen and capture the result in a QuickDraw PICT, but you'll lose much of
the information. There's no way to represent complex transfer modes, perspective,
advanced typography, and so on under the QuickDraw imaging model. By using the new
codec, you don't lose any of the QuickDraw GX features.
Note that this technique is quite different from that used in the older
PicturesAndPICTLibrary.c, which embeds a QuickDraw GX shape into a PICT by using
picture comments. We recommend that you use the codec instead because picture
comments have several weaknesses, including these:
• They're limited to 32K.
• Many applications strip out any picture comments they don't recognize.
• DrawPicture ignores all picture comments.
Using the codec to embed the QuickDraw GX picture avoids these problems.
QHow can I find out which printer is selected in the Chooser?
A Under the old printing architecture, you can locate the driver for the currently
selected printer by accessing the 'STR ' -8192 or 'alis' -8192 resource in the System
file. The 'STR ' -8192 resource contains the name of the current driver and the 'alis'
resource contains an alias record that will take you right to the driver. Note that with
older system software the 'alis' resource doesn't appear in the System file. If the 'alis'
resource is present, resolve it; if not, look in the Extensions folder and in the System
Folder for a file with the same name as 'STR ' -8192.
With QuickDraw GX installed, the 'STR ' -8192 resource still exists for backward
compatibility with applications that don't use QuickDraw GX printing. In this case the
'STR ' -8192 resource gives the name of the default desktop printer file. For
applications that are QuickDraw GX savvy, the concept of a default printer isn't
important because the user can pick any printer from the QuickDraw GX Print dialog.
Once you've located the 'STR ' -8192 resource and you have the name of the current
printer, you can then determine the printer's zone and type using the 'PAPA' -8192
resource in the driver (if the traditional printing architecture is in use) or by
accessing the printer's 'comm' resource (if the QuickDraw GX printing architecture is
in use). Sample code demonstrating this can be found in the Macintosh Technical Q&A
"Locating the Selected Printer" (GXPD 36).
QWhen I call FDecompressImage during printing, it appears that the custom StdPix
bottleneck of the LaserWriter 8.3 driver isn't called. Why not?
A FDecompressImage doesn't call through the StdPix bottleneck. The workaround is
to directly call the StdPix bottleneck in the current graphics port (or the StdPix
obtained from calling SetStdCProcs if there are no custom bottlenecks in the current